package chapter05

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test02_FunDefine
 * Package: chapter05
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-19
 *          Time: 14:38
 */

object Test02_FunDefine {
  def main(args: Array[String]): Unit = {
    //1.函数1 无参 无返回值
    def f1():Unit = {
      println("1.无参 无返回值")
    }
    f1()

    //2.函数2 无参 有返回值
    def f2():String = {
      return "2.无参 有返回值"
    }
    val d2 = f2()
    println(d2)

    //3.函数三 有参 有返回值
    def f3(name :String):String = {
      return name
    }
    val d3 = f3("3.有参 有返回值")
    println(d3)

    //4.有参无返回值
    def f4(name:String):Unit = {
      println(name)
    }
    f4("4.有参 无返回值")

    //5.多参 无返回值
    def f5(name:String,name2:String):Unit = {
      println("5."+name +" " + name2)
    }
    f5("多参","无返回值")

    //6.多参 有返回值
    def f6(name:String,age:Int):String = {
      age + "岁的" +name
    }
    val b6 = f6("可乐",20)
    println(b6)
  }
}
